# @Time     : 2025-04-10 10:24
# @Author  : Fioman
# @Phone    : 13149920693
#  @Motto   : Talk is cheap,show me the code ^_^

from urllib.request import urlopen

url = r"https://www.baidu.com"
resp = urlopen(url)
respContent = resp.read() # 返回的是字节流,read的原理是将数据移动的字节流的末尾,是单次的
print(respContent,type(respContent))
with open("mybaidu.html", mode= "w",encoding="utf-8") as f:
    f.write(respContent.decode("utf-8")) # 将字节流解码为字符串
